package login;

import java.io.UnsupportedEncodingException;

import network.enums.ServerPackets;
import network.requests.LoginRequest;
import network.requests.RegisterRequest;
import app.AppGlobals;

public class LoginHandler {


	public static void sendLogin(String userName, String password){
		try {
			AppGlobals.gameServer.sendPacket(
					ServerPackets.Login,AppGlobals.gson.toJson(
							new LoginRequest(userName,
									AppGlobals.hashPasswrod(password),
									"TEST")
							).getBytes("utf-8")
					);
			System.out.println(AppGlobals.hashPasswrod(password));
		} catch (UnsupportedEncodingException e) {
			System.out.println("sending login request failed");
			e.printStackTrace();
		}
	
	}
	
	public static void sendRegister(String userName, String password){
		try {
			AppGlobals.gameServer.sendPacket(
					ServerPackets.Register,AppGlobals.gson.toJson(
							new RegisterRequest(userName,
									AppGlobals.hashPasswrod(password), "TEST")
							).getBytes("utf-8")
					);
		} catch (UnsupportedEncodingException e) {
			System.out.println("sending register request failed");
			e.printStackTrace();
		}

	}
}
